<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body>
    <h1>Jquery</h1>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
    <script>
      // let request = $.get(
      //   "https://api.github.com/search/repositories?q=javascript&sort=stars"
      // );
      function getData() {
        return new Promise((resolve, reject) => {
          $.ajax({
            url:
              "https://api.github.com/search/repositories?q=javascript&sort=stars",
            type: "GET",
            success: function(data) {
              resolve(data);
            },
            error: function(err) {
              resolve(err);
            }
          });
        });
      }

      // getData()
      //   .then(function(data) {
      //     console.log(data);
      //   })
      //   .catch(function(err) {
      //     console.log(err);
      //   });

      let request = $.ajax({
        url:
          "https://api.github.com/search/repositories?q=javascript&sort=stars",
        type: "GET"
      });
      request.done(data => console.log(data)).fail(err => console.log(err));
    </script>
  </body>
</html>
